<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('风险名称列表')"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            <label>风险编码：</label>
                            <input type="text" name="riskCode"/>
                        </li>
                        <li>
                            <label>所属系统：</label>
                            <select name="sysId" id="sysId" th:with="item=${@dict.selectHiddenSysList()}" onchange="createProList()">
                                <option value="">所有</option>
                                <option th:each="dict : ${item}" th:text="${dict.sysName}"
                                        th:value="${dict.sysId}"></option>
                            </select>
                        </li>
                        <li>
                            <label>所属环节：</label>
                            <select name="linkId" id="linkId" th:with="item=${@dict.selectHiddenSysList()}">
                                <option value="">请选择所属环节</option>
                            </select>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="hidden:hiddenName:add">
                <i class="fa fa-plus"></i> 添加
            </a>
            <a class="btn btn-primary single disabled" onclick="$.operate.edit()"
               shiro:hasPermission="hidden:hiddenName:edit">
                <i class="fa fa-edit"></i> 修改
            </a>
            <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()"
               shiro:hasPermission="hidden:hiddenName:remove">
                <i class="fa fa-remove"></i> 删除
            </a>
            <!--<a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="hidden:hiddenName:export">
                <i class="fa fa-download"></i> 导出
            </a>-->
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('hidden:hiddenName:edit')}]];
    var removeFlag = [[${@permission.hasPermi('hidden:hiddenName:remove')}]];
    var prefix = ctx + "hidden/hiddenName";

    $(function () {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            modalName: "风险名称",
            columns: [{
                checkbox: true
            },
                {
                    field: 'riskId',
                    title: '',
                    visible: false
                },
                {
                    field: 'riskCode',
                    title: '风险编码'
                },
                {
                    field: 'riskName',
                    title: '风险名称'
                },
                {
                    field: 'sysName',
                    title: '所属系统'
                },
                {
                    field: 'linkName',
                    title: '所属环节'
                },
                {
                    field: 'riskLevel',
                    title: '风险等级'
                },
                /* {
                    field: 'riskEle',
                    title: '风险要素'
                },
                {
                    field: 'workAddr',
                    title: '作业地点'
                },
                {
                     field: 'taskName',
                     title: '任务名称'
                 },
                 {
                     field: 'executeUnit',
                     title: '执行单位'
                 },
                 {
                     field: 'suitPost',
                     title: '适用岗位'
                 },

                 {
                     field: 'riskValue',
                     title: '风险值'
                 },
                 {
                     field: 'riskType',
                     title: '风险类型'
                 },
                 {
                     field: 'riskContent',
                     title: '风险内容'
                 },
                 {
                     field: 'riskResult',
                     title: '风险后果'
                 },
                 {
                     field: 'passFeature',
                     title: '合格特征'
                 },
                 {
                     field: 'checkCycle',
                     title: '检查周期'
                 },
                 {
                     field: 'reformIdea',
                     title: '整改措施'
                 },*/
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.riskId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.riskId + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });

    function createProList() {
        var _linkId = $("#linkId").empty();
        _linkId.append('<option value="">请选择所属环节</option>')
        var val = $('#sysId  option:selected').val();
        if(val){
            $.post(ctx+"/hidden/hiddenLink/queryLinkList",{sysId:val},function (res) {
                $.each(res,function (i,item) {
                    _linkId.append(' <option value="'+item.linkId+'">'+item.linkName+'</option>')
                })
            })
        }
    }
</script>
</body>
</html>